define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'xiluhouse/user/user_auth/index' + location.search,
                    add_url: '',
                    edit_url: 'xiluhouse/user/user_auth/edit',
                    del_url: 'xiluhouse/user/user_auth/del',
                    multi_url: '',
                    table: 'xiluhouse_user_auth',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'user_id', title: __('User_id')},
                        {field: 'is_broker', title: __('Is_broker'), searchList: {"1":__('Is_broker 1'),"2":__('Is_broker 2')}, formatter: Table.api.formatter.normal},
                        {field: 'username', title: __('Username'), operate: 'LIKE'},
                        {field: 'mobile', title: __('Mobile'), operate: 'LIKE'},
                        {field: 'city', title: __('city'), operate: 'LIKE'},
                        {field: 'community', title: __('community'), operate: 'LIKE'},
                        {field: 'house_number', title: __('house_number'), operate: 'LIKE'},
                        {field: 'price', title: __('price'), operate: 'LIKE'},
                        
                        // {field: 'identify', title: __('Identify'), operate: 'LIKE'},
                        // {field: 'id_face', title: __('Id_face'), events: Table.api.events.image, formatter: Table.api.formatter.image,operate:false},
                        // {field: 'id_back', title: __('Id_back'), events: Table.api.events.image, formatter: Table.api.formatter.image,operate:false},
                        // {field: 'house_certification', title: __('House_certification'), events: Table.api.events.image, formatter: Table.api.formatter.image,operate:false},
                        // {field: 'village_ids', title: __('Village_ids'), operate: 'LIKE'},
                        {field: 'check_status', title: __('Check_status'), searchList: {"0":__('Check_status 0'),"1":__('Check_status 1'),"2":__('Check_status 2')}, formatter: Table.api.formatter.status},
                        {field: 'checktime', title: __('Checktime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime,visible:false},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
